<script>

    jxt.imglist.render = function (node, edit, noRenderChild, tpname){
        if ($.type(node) == "string") node = jxt.getnode(node);
        var arr= node.content ;
        node.temp.lastindex= ( arr.length-1 )%4;
        jxt.tag.render(node, edit, noRenderChild, tpname);
    };
    jxt.imglist.delimg = function (eleid, i) {
        if (!confirm("del?")) return;
        var n = jxt.getnode(eleid);
        var arr = jxt.imglist.getdata(eleid);
        arr.splice(i, 1);
        n.content = arr;
        jxt.msg.radio(eleid, "nodechange");
        jxt.tag.render(n, true);
    };
    jxt.imglist.help_callback = function (subscribe_id, eventkey, attrs, event_source_id) {
        switch (eventkey) {
            case "help_img":
                jxt.imglist.addimg(subscribe_id, attrs);
                break;

        }
    };

    jxt.imglist.addimg = function (eleid, attrs) {
        if(!(attrs.src))return;
        var arr = jxt.imglist.getdata(eleid);
        arr.push(attrs.src);
        arr.push("");
        var node = jxt.getnode(eleid);
        node.content = arr;
        jxt.msg.radio(eleid, "nodechange");
        jxt.render(eleid, true);
    };

    jxt.imglist.editbegin=function (eleid) {
        var node = jxt.getnode(eleid);
       var arr= node.content ;
        arr.push("");
        node.content=arr;
        node.temp.lastindex= ( arr.length-1 )%4;
        jxt.tag.editbegin(eleid);
    };

    jxt.imglist.ok= function (eleid) {
        var n = jxt.getnode(eleid);
        var arr=jxt.imglist.getdata(eleid);
        if(arr&& arr.length>0){
            n.content = arr;
            jxt.msg.radio(eleid, "nodechange");
        }
        jxt.tag.ok(eleid);
    };


    jxt.imglist.getdata = function (eleid) {
        var arr = [];
        var img_arr = $("img[data-jxt-data='" + eleid + "']");
        for (var i = 0; i < img_arr.length; i++) {
            var v=$(img_arr[i]).attr('src');
            if(v)arr.push(v);
        }
        return arr;
    };

    jxt.imglist.children = function () {
        return null;
    };
    jxt.imglist.add = function () {
    };

    jxt.imglist.create = function (subscribe_id, eventkey, attrs, event_source_id) {
        var node = jxt.newJson('imglist');
        if (attrs && attrs.tpname) {
            node.tpname = attrs.tpname;
        }
        jxt.msg.radio("imglist", "addmainnode", {"newnodelist": node});
        jxt.route.exe('imglist.editbegin', null, node.id);
    };
    jxt.msg.subscribe("imglist", "createimglist", jxt.imglist.create);
</script>